import { IoAdapter } from '@nestjs/platform-socket.io';
import { INestApplicationContext } from '@nestjs/common';
// import { ConfigService } from '@nestjs/config';

// https://stackoverflow.com/questions/69435506/how-to-pass-a-dynamic-port-to-the-websockets-gateway-in-nestjs
export class SocketIoAdapter extends IoAdapter {
  constructor(app: INestApplicationContext) {
    super(app);
  }

  create(port: number, options?: any) {
    port = 7002;
    options.path = '/ws-api';
    options.namespace = '/admin';
    return super.create(port, options);
  }

  createIOServer(port: number, options?: any) {
    port = 7002;
    options.path = '/ws-api';
    options.namespace = '/admin';
    return super.createIOServer(port, options);
  }
}
